//
//  tableHeaderView.m
//  FoodCorner
//
//  Created by Summer on 16/3/11.
//  Copyright © 2016年 zhangchao. All rights reserved.
//

#import "tableHeaderView.h"
#import <SDAutoLayout/UIView+SDAutoLayout.h>
@implementation TableHeaderView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self =  [super initWithFrame:frame]) {
        [self addAllViews];
    }
    return self;
}
- (void)addAllViews
{
    _titleImage = [UIImageView new];
//    _titleImage.layer.masksToBounds = YES;
    _titleImage.image = [UIImage imageNamed:@"timg"];
//    _titleImage.layer.cornerRadius  = 100 / 2;
    [self addSubview:_titleImage];
    
    _title = [UITextField new];
    _title.text = @"asdasda";
//    _title.backgroundColor = [UIColor blackColor];
    [self addSubview:_title];
    
    _infoText = [UILabel new];
    _infoText.text = @"asdffgererdasdad";
    _infoText.font = [UIFont systemFontOfSize:16];
    
//    _infoText.backgroundColor = [UIColor grayColor];
    [self addSubview:_infoText];
    
    _lineView = [UIView new];
//    _lineView.backgroundColor = [UIColor redColor];
    [self addSubview:_lineView];
    
    _addButton = [UIButton buttonWithType:(UIButtonTypeContactAdd)];
    [self addSubview:_addButton];

    
    CGFloat margin = 10;
   
    self.titleImage.sd_layout
    .centerXIs(self.center.x)
    .centerYIs(self.center.y - 50)
    .widthRatioToView(self,0.9)
    .heightIs(120);
    
    self.title.sd_layout
    .leftSpaceToView(self ,margin * 2 + 5)
    .topSpaceToView(self.titleImage ,margin / 2)
    .rightSpaceToView(self ,margin)
    .heightIs(20);
    
    self.infoText.sd_layout
    .topSpaceToView(self.title,margin / 2)
    .leftSpaceToView(self.addButton,margin)
    .rightSpaceToView(self,margin)
    .heightIs(60);
    
    self.addButton.sd_layout
    .topSpaceToView(self.title,margin * 2 + 10)
    .leftSpaceToView(self,0)
    .rightSpaceToView(self.infoText,margin)
    .heightIs(15)
    .widthIs(15);
    
    _lineView.sd_layout
    .topSpaceToView(_infoText,margin)
    .rightSpaceToView(self,0)
    .leftSpaceToView(self,0)
    .heightIs(1);
    
    [self setupAutoHeightWithBottomView:_lineView bottomMargin:0];
    
    
    
    
}


@end
